<template>
  <div class="container">
    <!-- 这里重复元素两次以实现首尾相连 -->
    <div class="unit5-chart" id="unit5-result" style="width: 444px;height: 193px;background-color: tan"></div>
  </div>
</template>
<script>
import * as echarts from 'echarts'
import axios from 'axios'

export default {
  name: 'test',
  data () {
    return {
      marqueeText: '这里是跑马灯的文字内容',
      marqueeWidth: 0,
      unit5_result_data: {
        sample_num: "",
      },
    }
  },
  methods: {
    getUnit5ResultData () {
      axios.get('/admin/unit5/resultData').then(res => {
        if (res.status !== 200) {
          console.log('http_status 异常', res.status)
          return
        }
        if (res.data.code !== 0) {
          console.log('api message: ', res.data.message)
          return
        }
        let result = res.data.data
        console.log("resultData",result)
        this.createUnit5EChart1(result.xLine,result.yLine)
        // this.notice_list = res.data.data.list
      }).catch(err => {
        console.log('getNoticeList error', err)
      })
    },
  createUnit5EChart1(xLine,yLine) {
      let option = {
        grid: {
          left: 0,
          right: 0,
          top: 0,
          bottom: 0,
        },
        xAxis: {
          type: 'category',
          data: xLine,
          axisLabel: {
            color: '#ff0000',
          },
        },
        yAxis: {
          type: 'value',
          axisLabel: {
            color: '#ff0000',
          },
        },
        series: [
          {
            data: yLine,
            type: 'line',

          }
        ]
      };

      if (!this.myChart) {
        this.myChart = echarts.init(document.getElementById('unit5-result'))
      }
      option && this.myChart.setOption(option)
      // console.log('option:', option)
    }
  },
  mounted () {
    // 添加动画类
    this.getUnit5ResultData()
  }
}
</script>
<style>
.container {
  width: 100%;
}
</style>
